package io.bsly.modules.sys.controller;

import io.bsly.common.utils.PageUtils;
import io.bsly.common.utils.R;
import io.bsly.modules.app.entity.sourceEntity.RoomTypeEntity;
import io.bsly.modules.app.pojo.HotelRoomTypeVo;
import io.bsly.modules.app.pojo.RoomTypeFrom;
import io.bsly.modules.app.service.sourceDb.RoomTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;
import java.util.Map;

/**
 *  物理房型
 */
@Api(tags = "后台物理房型")
@RestController
@RequestMapping("sys/roomtype")
public class SysRoomTypeController {
    @Autowired
    private RoomTypeService roomTypeService;

    /**
     * 分页列表
     */
    @GetMapping("/queryPage")
    public R listPage(@RequestParam Map<String, Object> params){
        PageUtils page = roomTypeService.queryPage(params);
        return R.ok().put("page", page);
    }

    /**
     * 后台明细 获取房型信息
     */
    @ApiOperation("获取房型信息")
    @GetMapping("/getDetailWithTypeData")
    public R getDetailWithTypeData(@RequestParam("hotelId") Integer hotelId){
        List<HotelRoomTypeVo> list = roomTypeService.getDetailWithTypeData(hotelId);
        return R.ok().put("list", list);
    }

    /**
     * 信息
     */
    @GetMapping("/info/{id}")
    public R info(@PathVariable("id") Integer id){
		RoomTypeEntity roomType = roomTypeService.getById(id);
        return R.ok().put("roomType", roomType);
    }

}
